<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  const person = {
    name: '张三',
    age: 18
  }

  Function.prototype.myApply = function (thisArgs, argsArray) {
    if (!argsArray instanceof Array) {
      return new Error('参数必须是数组')
    }
    const property = Symbol('property')
    thisArgs[property] = this
    const result = thisArgs[property](...argsArray)
    delete thisArgs[property]
    return result
  }

  function test(a, b) {
    console.log(this)
    console.log(a, b)
    return a + b
  }

  test.myApply(person, [1, 2])
</script>
</body>
</html>